const router = require('koa-router')(),
  spotslist=require('../models/spots');


router.prefix('/spots')

router.get('/', async function (ctx, next) {
    ctx.body=await spotslist.getSpots();
})

router.get('/byid', async function (ctx, next) {
    const {id}=ctx.query
    ctx.body=await spotslist.getSpotById(id);
})

router.get('/detail', async function (ctx, next) {
  const {id}=ctx.query
  ctx.body=await spotslist.getSpotByIdDetail(id);
})

router.get('/byname', async function (ctx,next){
  const {name}=ctx.query
  ctx.body=await spotslist.getSpotByName(name);
  // ctx.body=name;
})

module.exports = router